<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let obj={
            name:"dsf",
            hobbby:{
                run1:"sf",
                run2:"dfgf"
            },
            play:function(){
                console.log(43546);
            }
        }

        // 深克隆
function deepCopy(value) { 
	if(value instanceof Function)return value
    else if (value instanceof Array) {
        var newValue = []
        for (let i = 0; i < value.length; ++i) newValue[i] = deepCopy(value[i])
        return newValue
    } else if (value instanceof Object) {
        var newValue = {}
        for (let i in value) newValue[i] = deepCopy(value[i])
        return newValue
    } else return value
}

let obj2=deepCopy(obj)
obj2.hobbby.run1="范德萨"
console.log(obj,obj2);
    </script>
</body>
</html>